package com.peiqi.aiproject.controller;

import cn.hutool.http.HttpStatus;
import com.peiqi.aiproject.domain.LoginDTO;
import com.peiqi.aiproject.domain.vo.ResponseVO;
import com.peiqi.aiproject.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录相关接口
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @Resource
    UserService userService;

    /**
     * 登录接口
     * @param loginDTO 登录对象
     * @return String token
     */
    @PostMapping()
    public ResponseVO<String> login(@RequestBody LoginDTO loginDTO){
        String token = userService.login(loginDTO);
        return ResponseVO.success(HttpStatus.HTTP_CREATED,token);
    }

}
